#ifndef NETLIB_POLLPOLLER_H
#define NETLIB_POLLPOLLER_H

#include "Poller.h"

#include <vector>

struct pollfd;

namespace netlib
{

namespace net
{

class PollPoller : public Poller
{
public:

    PollPoller(EventLoop* loop);
    
    ~PollPoller() override;

    Timestamp poll(int timeoutMs, ChannelList* activeChannels) override; // 调用::poll

    void updateChannel(Channel* channel) override; // 更新事件表

    void removeChannel(Channel* channel) override; // 移除一个通道

private:

    // 将有就绪事件的通道添加到活动通道列表
    void fillActiveChannels(int numEvents,
                            ChannelList* activeChannels) const;

    typedef std::vector<struct pollfd> PollFdList;
    PollFdList pollfds_;          // 向量，存储pollfd数组，作poll的第一个参数

}; // class PollPoller end

}  // namespace net end

}  // namespace netlib end
#endif